//
//  JLVersionUpdate.m
//  JiuLe
//
//  Created by xcq on 15/12/25.
//  Copyright © 2015年 Fine. All rights reserved.
//

#import "Common.h"
#import "JLVersionUpdate.h"

@implementation JLVersionUpdate

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"关于我们";
    [self showNavBarWithRightTitle:nil
                    andRightAction:nil
                     andLeftAction:@selector(homeControllerBackTo)
                 andRightBtnIsShow:NO];
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    CFShow((__bridge CFTypeRef)(infoDic));
    NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];

    _currenVersion.text = [@"当前版本" stringByAppendingString:currentVersion];
    [Common checkVersionUpdate:^(BOOL isSuccess, BOOL isUpdate, BOOL isNewfeatures, NSDictionary *updateInfo) {
        if (isSuccess && isUpdate) {
            _updateBtn.hidden = NO;
            _bestVersion.hidden = NO;
            _bestVersion.text = [@"最新版本" stringByAppendingString:[updateInfo objectForKey:@"version"]];
            [_updateBtn setTitle:@"有新版本可供下载" forState:UIControlStateNormal];
         } else {
             _updateBtn.hidden = YES;
             _bestVersion.hidden = YES;
         }
    }];
    
}

- (IBAction)updateAction:(id)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/ebus/id%@?mt=8&uo=4",kAPPID]]];

}
@end
